package day04;

import java.util.Random;
import java.util.Scanner;

public class _GenEx07 {                                          //双色球系统
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] numArr=new int[7];
        for(int i=0;i<6;i++){
            System.out.println("请输入第"+(i+1)+"个红球号码，范围为1-33，红球之间不能同号");
            numArr[i]=sc.nextInt();
        }
        System.out.println("请输入第7个球号码，范围为1-16");
        numArr[6]=sc.nextInt();
        ifWin(numArr,ranBall());
    }
    public static int[] ranBall() {
        Random rand = new Random();
        int[] ranArr = new int[7];
        for(int i=0;i<6;){
            int ranRed = rand.nextInt(33)+1;
            boolean flag = false;
            for(int j=0;j<6;j++){
                if(ranRed==ranArr[j]){
                    flag = true;
                    break;
                }
            }
            if(!flag) {
                ranArr[i] = ranRed;
                i++;
            }
        }
        ranArr[6]=rand.nextInt(16)+1;
        return ranArr;
    }
    public static void ifWin(int[] num,int[] winNum) {
        int count=0;
        for(int i=0;i<6;i++){
            for(int j=0;j<6;j++){
                if(num[i]==winNum[j]){count++;}
            }
        }
        if(num[6]==winNum[6]){count++;}
        boolean blue=false;
        if(num[6]==winNum[6]) blue=true;
        int prize=0;
        int lv=0;
        if((count<=3&&count>=2)||(count==1&&blue)) {
            prize=5;
            lv=6;
        }
        else if(count==4) {
            prize=10;
            lv=5;
        }
        else if(count==5) {
            prize=200;
            lv=4;
        }
        else if(count==6&&blue) {
            prize=3000;
            lv=3;
        }
        else if(count==6&&(!blue)) {
            prize=5000000;
            lv=2;
        }
        else if(count==7) {
            prize=10000000;
            lv=1;
        }
        System.out.println("中奖号码是：");
        for(int i=0;i<num.length;i++){
            System.out.print(winNum[i]+" ");
        }
        if(count>=1) System.out.println("\n恭喜您获得"+lv+"等奖,奖金是"+prize+"元！");
        else System.out.println("抱歉，您未中奖！");
    }
}
